package com.vinci.webtrading.dao.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name="OPERATION")

public class Operation {

	private Integer id;
	private String libelleDevise;
	private Double montant;
	private Double tauxOuverture;
	private Double tauxActuel;
	private Double benefice;
	private Double risque;
	private Double seuilPerte;
	private String typeOperation;
	private Devise devise;
	private Historique historique;
	private Client client;
		
		
	public Operation() {
		super();
		// TODO Auto-generated constructor stub
	}
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="OPERATION_ID")
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(name="LIBELLEDEVISE")
	public String getLibelleDevise() {
		return libelleDevise;
	}
	public void setLibelleDevise(String libelleDevise) {
		this.libelleDevise = libelleDevise;
	}
	
	@Column(name="MONTAN")
	public Double getMontant() {
		return montant;
	}
	public void setMontant(Double montant) {
		this.montant = montant;
	}
	
	@Column(name="TAUXOUVERTURE")
	public Double getTauxOuverture() {
		return tauxOuverture;
	}
	public void setTauxOuverture(Double tauxOuverture) {
		this.tauxOuverture = tauxOuverture;
	}
	
	@Column(name="TAUXACTUEL")
	public Double getTauxActuel() {
		return tauxActuel;
	}
	public void setTauxActuel(Double tauxActuel) {
		this.tauxActuel = tauxActuel;
	}
	
	@Column(name="BENEFICE")
	public Double getBenefice() {
		return benefice;
	}
	public void setBenefice(Double benefice) {
		this.benefice = benefice;
	}
	
	@Column(name="RISQUE")
	public Double getRisque() {
		return risque;
	}
	public void setRisque(Double risque) {
		this.risque = risque;
	}
	
	@Column(name="SEUILPERTE")
	public Double getSeuilPerte() {
		return seuilPerte;
	}
	public void setSeuilPerte(Double seuilPerte) {
		this.seuilPerte = seuilPerte;
	}
	
	@Column(name="TYPEOPERATION")
	public String getTypeOperation() {
		return typeOperation;
	}
	public void setTypeOperation(String typeOperation) {
		this.typeOperation = typeOperation;
		
	}
	
	@OneToMany(mappedBy="operation", fetch=FetchType.LAZY)
	public Devise getDevise() {
		return devise;
	}
	public void setDevise(Devise devise) {
		this.devise = devise;
	}
	
	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinTable(name = "OPERATION_HISTORIQUE", joinColumns = { @JoinColumn(name = "OPERATION_ID") }, inverseJoinColumns = { @JoinColumn(name = "HISTORIQUE_ID") })
	public Historique getHistorique() {
		return historique;
	}
	public void setHistorique(Historique historique) {
		this.historique = historique;
	}
	
	@ManyToOne
	@JoinColumn(name = "CLIENT_ID")
	public Client getClient() {
		return client;
	}
	public void setClient(Client client) {
		this.client = client;
	}
	@Override
	public String toString() {
		return "Operation [id=" + id + ", libelleDevise=" + libelleDevise
				+ ", montant=" + montant + ", tauxOuverture=" + tauxOuverture
				+ ", tauxActuel=" + tauxActuel + ", benefice=" + benefice
				+ ", risque=" + risque + ", seuilPerte=" + seuilPerte
				+ ", typeOperation=" + typeOperation + "]";
	}
	
	
	
	
	
	
	
}
